from . import fileutil, strutil


# 读取 key-value 型配置文件
def load_config(name: str, sep=':'):
    conf = {}

    lines = fileutil.read_lines(name)
    if not lines:
        return None

    for line in lines:
        line = line.strip()

        if line.startswith('#'):
            # 以井号开头的为注释
            continue

        key, value = strutil.parse_line(line, sep)

        if key is not None:
            conf[key] = value

    return conf
